package com.caseProject.puremvc.model.vo
{
	import com.caseProject.puremvc.model.Diagram;
	import com.caseProject.puremvc.model.DiagramNames;
	
	public class DiagramActivityVO extends Diagram
	{
		private var _elements:Vector.<ElementVO>;
		private var _transitions:Vector.<TransitionVO>;
		private var _partitions:Vector.<PartitionVO>;
				
		public function DiagramActivityVO()
		{
			super();
			this._elements = new Vector.<ElementVO>();
			this._transitions = new Vector.<TransitionVO>();
			this._partitions = new Vector.<PartitionVO>();
						
			this.icon = "assets/actIcon.png";
		}
		
		override public function get type():String
		{
			return DiagramNames.ACTIVITY;
		}

		public function get partitions():Vector.<PartitionVO>
		{
			return _partitions;
		}

		public function addPartition(value:PartitionVO):void
		{
			this._partitions.push(value);
		}
		
		public function addPartitions(value:Vector.<PartitionVO>):void
		{
			this._partitions = value;
		}

		public function get transitions():Vector.<TransitionVO>
		{
			return _transitions;
		}
		
		public function addTransition(value:TransitionVO):void
		{
			this._transitions.push(value);
		}
		
		public function addTransitions(value:Vector.<TransitionVO>):void
		{
			this._transitions = value;
		}

		public function get elements():Vector.<ElementVO>
		{
			return _elements;
		}

		public function addElement(value:ElementVO):void
		{
			this._elements.push(value);
		}
		
		public function addElements(value:Vector.<ElementVO>):void
		{
			this._elements = value;
		}
		
		public function toString ():String
		{
			var tag:String = '\t\t<state id="' + this.id + '" name="' + this.name + '">\n' +
				'\t\t\t<elements>\n' + 
				this.elementsTag() +
				'\t\t\t</elements>\n' +
				'\t\t\t<transitions>' + 
				this.transitionsTag() + 
				'\t\t\t</transitions>\n' +
				'\t\t\t<partitions>' + 
				this.partitionsTag() + 
				'\t\t\t</partitions>\n' +
				'\t\t</state>';
			return tag;
		}
		
		private function elementsTag():String
		{
			var tag:String = "";
			
			for (var i:int = 0; i < this.elements.length; i++)
			{
				tag += '\t\t\t\t'+ this.elements[i].toString() + '\n';
			}
			return tag;
		}
		
		private function transitionsTag():String
		{
			var tag:String = "";
			
			for (var i:int = 0; i < this.transitions.length; i++)
			{
				tag += '\t\t\t\t'+ this.transitions[i].toString() + '\n';
			}
			return tag;
		}
		
		private function partitionsTag():String
		{
			var tag:String = "";
			
			for (var i:int = 0; i < this.partitions.length; i++)
			{
				tag += '\t\t\t\t'+ this.partitions[i].toString() + '\n';
			}
			return tag;
		}
	}
}